#ifndef MONITORPOINTWIDGET_H
#define MONITORPOINTWIDGET_H

#include <QWidget>
#include "linechartwidget.h"
#include "barchartwidget.h"

class MonitorPointWidget : public QWidget
{
    Q_OBJECT
public:
    explicit MonitorPointWidget(const SerialConfig &config,QWidget *parent = nullptr);
    SerialConfig config() const { return m_config; }
    DataReader* reader() const { return m_reader; }
    void setDataReader(DataReader *reader);

signals:
    void monitorClosed(MonitorPointWidget *widget);
    void sendDataPoint(const DataPoint &data);

public slots:
    void updateCharts(const DataPoint &data);
    void closeMonitor();
    void handleError(const QString &error);

private:
    SerialConfig m_config;
    QPushButton *m_closeButton;
    QLabel *m_statusLabel;
    LineChartWidget *m_lineChart;
    BarChartWidget *m_barChart;
    DataReader *m_reader = nullptr;

};

#endif // MONITORPOINTWIDGET_H
